package cn.ac.ict.fpevaluation.cluster;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.ac.ict.fpevaluation.bean.AtomTrajectoryBean;

/**
 * ����AP����ǰ�Ƚ��г���ɸѡ
 * (�о�ûʲôЧ��)
 * @author Administrator
 *
 */
public class PreCluster {
	
	private List<AtomTrajectoryBean> atomTrajectoryBeanList = new ArrayList<AtomTrajectoryBean>();
	/**
	 * �����
	 */
	private Map<String, List<AtomTrajectoryBean>> result = new HashMap<String, List<AtomTrajectoryBean>>();
	
	/**
	 * �켣���Ȳ����20m����Ϊ������·��
	 */
	private final static int LengthClassify = 100;
	

	public List<List<AtomTrajectoryBean>> getArrayResult(List<AtomTrajectoryBean> atomTrajectoryBeanList) {
		this.atomTrajectoryBeanList = atomTrajectoryBeanList;
		classify();
		return new ArrayList<List<AtomTrajectoryBean>>(result.values());
	}
	
	/**
	 * ��η���(����·�����Ƚ��з���)
	 */
	private void classify() {
		if (atomTrajectoryBeanList.size() == 0) return;
		
		for (AtomTrajectoryBean temp : atomTrajectoryBeanList) {
			
			int trajectoryLength = (int)(temp.getStepLength() * temp.getStepList().size() / LengthClassify);
			
			String tempKey = "AtomTrajectoryBeanLength=" + trajectoryLength;

			if (result.containsKey(tempKey)) {
				result.get(tempKey).add(temp);
			} else {
				List<AtomTrajectoryBean> tempList = new ArrayList<AtomTrajectoryBean>();
				tempList.add(temp);
				result.put(tempKey, tempList);
			}
		}
	}
	
	public List<AtomTrajectoryBean> getatomTrajectoryBeanList() {
		return atomTrajectoryBeanList;
	}
}
